package com.example.springcloud.controller;

import com.example.springcloud.service.IMessageProvider;
import com.example.springcloud.service.UserService;
import com.example.springcloud.service.UserService1;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class SendMessageController {
    @Resource
    private IMessageProvider messageProvider;

    @Resource
    private UserService userService;
    @Resource
    private UserService1 userService1;

    @GetMapping(value = "/sendMessage")
    public String sendMessage() {
        return messageProvider.send();
    }

    @GetMapping(value = "/sendMessage2")
    public String sendMessage2() {
        return userService.sendBrandAdd();
    }

    /**
     *  默认情况下之前的程序都是属于广播消息，也就是说所有的消费者都可以接收发送消息内容，
     *  在 RabbitMQ 里面支持有直连消息，而直连消息主要是通过 RoutingKey 来实现，利用直连消息可以实现准确的消息消费端的接收处理。
     * @return
     */
    @GetMapping(value = "/sendMessage3")
    public String sendMessage3() {
        return userService1.sendBrandAdd();
    }

}
